home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / ex / Picture.c < prev    next >
C/C++ Source or Header  |  1990-05-15  |  2KB  |  74 lines

  1. // Picture.c -- A container for Shapes
  2.  
  3. #include "Picture.h"
  4. #include "nihclIO.h"
  5.  
  6. #define THIS Picture
  7. #define BASE Shape
  8. #define BASE_CLASSES Shape::desc()
  9. #define MEMBER_CLASSES OrderedCltn::desc()
  10. #define VIRTUAL_BASE_CLASSES
  11.  
  12. DEFINE_CLASS(Picture,1,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/ex/RCS/Picture.c,v 3.0 90/05/15 22:43:59 kgorlen Rel $",NULL,NULL);
  13.  
  14. void Picture::add(Shape& t)
  15. {
  16.     s.add(t);   // calls OrderedCltn::add()
  17. }
  18.  
  19. void Picture::draw() const
  20. {
  21.     printOn();
  22. }
  23.  
  24. bool Picture::operator==(const Picture& p) const
  25. {
  26.     if (origin() == p.origin())
  27.         if (s == p.s) return YES;
  28.     return NO;
  29. }
  30.  
  31. const Class* Picture::species() const   { return &classDesc; }
  32.  
  33. bool Picture::isEqual(const Object& p) const
  34. {
  35.     return p.isSpecies(classDesc) && *this==(const Picture&)p;
  36. }
  37.  
  38. unsigned Picture::hash() const
  39. {
  40.     return origin().hash() ^ s.hash();
  41. }
  42.  
  43. void Picture::deepenShallowCopy()
  44. {
  45.     Shape::deepenShallowCopy();
  46.     s.deepenShallowCopy();
  47. }
  48.  
  49. void Picture::printOn(ostream& strm) const
  50. {
  51.     TransformStack::transform.push(origin());
  52.     for (int i=0; i<s.size(); i++) {
  53.         ((Shape*)s[i])->printOn(strm);
  54.         strm << endl;
  55.     }
  56.     TransformStack::transform.pop();
  57. }
  58.  
  59. Picture::Picture(OIOin& strm) : Shape(strm),s(strm) {}
  60.  
  61. void Picture::storer(OIOout& strm) const
  62. {
  63.     Shape::storer(strm);
  64.     s.storeMemberOn(strm);
  65. }
  66.  
  67. Picture::Picture(OIOifd& fd) : Shape(fd),s(fd) {}
  68.  
  69. void Picture::storer(OIOofd& fd) const
  70. {
  71.     Shape::storer(fd);
  72.     s.storeOn(fd);
  73. }
  74.